$(function() {
    let index = parent.layer.getFrameIndex(window.name);
    parent.layer.iframeAuto(index);
    
    $(".select-item-fmea-dfmea-product").on("click", function() {
    	let $this = $(this);
        let id = $this.data("id");
        let $input = parent.clickTarget;
        if (parent.layui.$("td input[name='tempId'][value='" + id + "']").size() == 0) {
        	let productId = parent.$("input[name='productId']").val();
        	let action = parent.$("form").attr("action");
        	parent.location.href = action.slice(0, action.lastIndexOf("/")) + "/stepAdd/" + productId + "?tempId=" + id;
        } else {
            parent.layer.tips("已选择", $input.parents("td input[name='tempId'][value='" + id + "']"), {
                time : 3000
            });
        }
        parent.layer.close(index);
    });
    
    $(".select-item-fmea-dfmea-half").on("click", function() {
    	let $this = $(this);
        let id = $this.data("id");
        let $input = parent.clickTarget;
        if (parent.layui.$("td input[name='tempId'][value='" + id + "']").size() == 0) {
        	let halfId = parent.$("input[name='halfId']").val();
        	let action = parent.$("form").attr("action");
        	parent.location.href = action.slice(0, action.lastIndexOf("/")) + "/stepAdd/" + halfId + "?tempId=" + id;
        } else {
            parent.layer.tips("已选择", $input.parents("td input[name='tempId'][value='" + id + "']"), {
                time : 3000
            });
        }
        parent.layer.close(index);
    });
    
    $(".select-item-fmea-dfmea-material").on("click", function() {
    	let $this = $(this);
        let id = $this.data("id");
        let $input = parent.clickTarget;
        if (parent.layui.$("td input[name='tempId'][value='" + id + "']").size() == 0) {
        	let materialId = parent.$("input[name='materialId']").val();
        	let action = parent.$("form").attr("action");
        	parent.location.href = action.slice(0, action.lastIndexOf("/")) + "/stepAdd/" + materialId + "?tempId=" + id;
        } else {
            parent.layer.tips("已选择", $input.parents("td input[name='tempId'][value='" + id + "']"), {
                time : 3000
            });
        }
        parent.layer.close(index);
    });
    

});